import requests

from commons.entity.enum.base_url_enum import BaseUrlEnum
from commons.entity.po.travel import Travel


class TravelClient:
    def __init__(self):
        pass

    def get_all_travels_by_id_list(self, travel_id_list):
        url = f"{BaseUrlEnum.TRAVEL_SERVICE_URL.url}/travel/getAllTravelsByIdList"
        headers = {"Content-Type": "application/json"}
        response = requests.post(
            url, json={"travelIdList": travel_id_list}, headers=headers)

        if response.status_code == 200:
            travel_data = response.json()
            travels = [Travel(**data) for data in travel_data]
            return travels
        else:
            response.raise_for_status()
